package GUI;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;


public class CustomiseToolbar extends JFrame
{
	private JCheckBox allbox[];
	private String []list={"Play","Stop","Undo","Redo","Wire","AddGate"};
	public static String []temp={};
	private Icon []lists;
	private MButton select,cancel;
	private int j;
	private void load_image()
	{
		try
		{
			lists[0] = new ImageIcon( getClass().getResource("Play.png"));
			lists[1] = new ImageIcon( getClass().getResource("Stop.png"));
			lists[2] = new ImageIcon( getClass().getResource("reundo.png"));
			lists[3] = new ImageIcon( getClass().getResource("undo.png"));
			lists[4] = new ImageIcon( getClass().getResource("Wire.png"));
		}
		catch(Exception e)
		{
			JOptionPane.showMessageDialog(null, "An error occured");			
		}
	}
	CustomiseToolbar()
	{
		super("Customise Toolbar");
		lists = new Icon[5];
		load_image();
		select= new MButton("Select");
		cancel= new MButton("Cancel");
		JPanel panel=new JPanel();
		allbox = new JCheckBox[10];
		for(int i=0;i<list.length;i++)
		{
			allbox[i] = new JCheckBox(list[i],true);			
		}
		panel.setLayout(new FlowLayout());
		add(panel);				
		for(int i=0;i<list.length;i++)
		{			
			panel.add(allbox[i]);
		}	
		panel.add(select,BorderLayout.SOUTH);
		panel.add(cancel);
		j=0;
		select.addActionListener
		(
				new ActionListener()
				{
					public void actionPerformed(ActionEvent event)
					{
						try
						{
							for(int i=0;i<list.length;i++)
							{
								if(allbox[i].isSelected())
								{
									temp[j]=list[i];
									j++;
								}
							}
							WorkSpaceScreen.CreateToolbar();
							dispose();
						}
						catch(Exception e)
						{
							JOptionPane.showMessageDialog(null, "An error occured");
							dispose();
						}
					}
				}			
		);
		cancel.addActionListener
		(				
				new ActionListener()
				{
					public void actionPerformed(ActionEvent event)
					{
						dispose();
					}
				}
		);
	}	
}
